.TH "D:/FEUP/LCOM/WorkC/projecto/trunk/kbc.h" 3 "25 May 2010" "Colision" \" -*- nroff -*-
.ad l
.nh
.SH NAME
D:/FEUP/LCOM/WorkC/projecto/trunk/kbc.h \- 
.SH SYNOPSIS
.br
.PP
\fC#include 'timer.h'\fP
.br
\fC#include 'ints.h'\fP
.br
\fC#include 'utypes.h'\fP
.br
\fC#include 'queue.h'\fP
.br

.SS "Defines"

.in +1c
.ti -1c
.RI "#define \fBKBC_TIMEOUT\fP   30"
.br
.RI "\fImaximum amount of milliseconds to wait for KBC response/availability \fP"
.in -1c
.PP
.RI "\fBThe hardware register addresses\fP"
.br
 
.PP
.in +1c
.in +1c
.ti -1c
.RI "#define \fBCMD_REG\fP   0x64"
.br
.RI "\fIcommand register (read only) \fP"
.ti -1c
.RI "#define \fBSTAT_REG\fP   0x64"
.br
.RI "\fIstatus register (write only) \fP"
.ti -1c
.RI "#define \fBDATA_REG\fP   0x60"
.br
.RI "\fIdata register (read/write) \fP"
.in -1c
.in -1c
.PP
.RI "\fBBit meanings in the status register\fP"
.br
 
.PP
.in +1c
.in +1c
.ti -1c
.RI "#define \fBOBF\fP   (1 << 0)"
.br
.RI "\fIOutput Buffer Full. \fP"
.ti -1c
.RI "#define \fBIBF\fP   (1 << 1)"
.br
.RI "\fIInput Buffer Full. \fP"
.ti -1c
.RI "#define \fBAUX\fP   (1 << 5)"
.br
.RI "\fI1 if data at DATA_REG came from mouse interface \fP"
.ti -1c
.RI "#define \fBPAR_ERR\fP   (1 << 7)"
.br
.RI "\fIParity Error. \fP"
.ti -1c
.RI "#define \fBTO_ERR\fP   (1 << 6)"
.br
.RI "\fITimeout Error. \fP"
.in -1c
.in -1c
.PP
.RI "\fB'Historical' commands to send to DATA_REG, response in DATA_REG\fP"
.br
 
.PP
.in +1c
.in +1c
.ti -1c
.RI "#define \fBResetKBC\fP   0xFF"
.br
.RI "\fIReset the KBC interface. \fP"
.ti -1c
.RI "#define \fBDefaultKBD\fP   0xF6"
.br
.RI "\fISet default scancode and repeat rate. \fP"
.ti -1c
.RI "#define \fBDisableKBD\fP   0xF5"
.br
.RI "\fIHistorical Disable keyboard. \fP"
.ti -1c
.RI "#define \fBEnableKBD\fP   0xF4"
.br
.RI "\fIHistorical clear buffer and enable keyboard. \fP"
.ti -1c
.RI "#define \fBKBDRate\fP   0xF3"
.br
.RI "\fIKeyboard repeat rate, one arg, bits 0-4 repeat rate, bits 5-6 start delay. \fP"
.ti -1c
.RI "#define \fBWriteLEDS\fP   0xED"
.br
.RI "\fITurn on/off KBD LEDS, one arg, one bit per led, bits 0-2, 0-off, 1-on. \fP"
.ti -1c
.RI "#define \fBSCROLL_LOCK\fP   (1 << 0)"
.br
.RI "\fISCROLL_LOCK led for WriteLEDS command. \fP"
.ti -1c
.RI "#define \fBNUM_LOCK\fP   (1 << 1)"
.br
.RI "\fINUM__LOCK led for WriteLEDS command. \fP"
.ti -1c
.RI "#define \fBCAPS_LOCK\fP   (1 << 2)"
.br
.RI "\fICAPS_LOCK led for WriteLEDS command. \fP"
.in -1c
.in -1c
.PP
.RI "\fBResponse codes to commands/data written in DATA_REG\fP"
.br
 
.PP
.in +1c
.in +1c
.ti -1c
.RI "#define \fBACK\fP   0xFA"
.br
.RI "\fIAcknowledge OK response. \fP"
.ti -1c
.RI "#define \fBResend\fP   0xFE"
.br
.RI "\fIResend error response; on multibyte commands the whole command must be resent from the beginning. \fP"
.ti -1c
.RI "#define \fBError\fP   0xFC"
.br
.RI "\fIError. \fP"
.in -1c
.in -1c
.PP
.RI "\fBCommand codes to send to CMD_REG, args, if exists, to DATA_REG, return values in DATA_REG\fP"
.br
 
.PP
.in +1c
.in +1c
.ti -1c
.RI "#define \fBReadCommand\fP   0x20"
.br
.RI "\fIRead Command_Byte. \fP"
.ti -1c
.RI "#define \fBWriteCommand\fP   0x60"
.br
.RI "\fIWrite Command_Byte, one arg. \fP"
.ti -1c
.RI "#define \fBDisableMouse\fP   0xA7"
.br
.RI "\fIDisable Mouse Interface. \fP"
.ti -1c
.RI "#define \fBEnableMouse\fP   0xA8"
.br
.RI "\fIEnable Mouse Interface. \fP"
.ti -1c
.RI "#define \fBTestMouse\fP   0xA9"
.br
.RI "\fITest Mouse Interface, returns 0 if OK. \fP"
.ti -1c
.RI "#define \fBTest8042\fP   0xAA"
.br
.RI "\fITest KBC, returns 0x55 if sucess, 0xFC on error. \fP"
.ti -1c
.RI "#define \fBTestKBD\fP   0xAB"
.br
.RI "\fITest mouse, returns 0 if OK. \fP"
.ti -1c
.RI "#define \fBNDisableKBD\fP   0xAD"
.br
.RI "\fINew (versus historical) Disable keyboard. \fP"
.ti -1c
.RI "#define \fBNEnableKBD\fP   0xAE"
.br
.RI "\fINew (versus historical) Enable keyboard. \fP"
.ti -1c
.RI "#define \fBWriteMouse\fP   0xD4"
.br
.RI "\fIWrite Mouse, one arg, see 'Commands for the Mouse'. \fP"
.ti -1c
.RI "#define \fBResetPC\fP   0xFE"
.br
.RI "\fIReset PC (reboot). \fP"
.in -1c
.in -1c
.PP
.RI "\fBBit meanings in the Command_Byte\fP"
.br
 (read/write with command ReadCommand/WriteCommand) 
.PP
.in +1c
.in +1c
.ti -1c
.RI "#define \fBINT_1\fP   (1 << 0)"
.br
.RI "\fIEnable generation of interrupts from keyboard. \fP"
.ti -1c
.RI "#define \fBINT_12\fP   (1 << 1)"
.br
.RI "\fIEnable generation of interrupts from mouse. \fP"
.ti -1c
.RI "#define \fBEN_KBD\fP   (1 << 4)"
.br
.RI "\fIEnable keyboard interface (zero enables, one disables). \fP"
.ti -1c
.RI "#define \fBEN_MOUSE\fP   (1 << 5)"
.br
.RI "\fIEnable mouse interface (zero enables, one disables). \fP"
.in -1c
.in -1c
.PP
.RI "\fBCommands to the Mouse\fP"
.br
 Prefaced with command WriteMouse 
.PP
.in +1c
.in +1c
.ti -1c
.RI "#define \fBMouseReset\fP   0xFF"
.br
.ti -1c
.RI "#define \fBMouseDefaults\fP   0xF6"
.br
.ti -1c
.RI "#define \fBStreamDisable\fP   0xF5"
.br
.ti -1c
.RI "#define \fBStreamEnable\fP   0xF4"
.br
.ti -1c
.RI "#define \fBSampleRate\fP   0xF3"
.br
.ti -1c
.RI "#define \fBReadDevice\fP   0xF2"
.br
.ti -1c
.RI "#define \fBRemoteMode\fP   0xF0"
.br
.ti -1c
.RI "#define \fBMouseReadData\fP   0xEB"
.br
.ti -1c
.RI "#define \fBEnterStream\fP   0xEA"
.br
.ti -1c
.RI "#define \fBStatusRequest\fP   0xE9"
.br
.ti -1c
.RI "#define \fBResolution\fP   0xE8"
.br
.ti -1c
.RI "#define \fBScaling2\fP   0xE7"
.br
.ti -1c
.RI "#define \fBScaling1\fP   0xE6"
.br
.in -1c
.in -1c
.PP
.RI "\fBBit meaning in first byte of mouse data packet\fP"
.br
 
.PP
.in +1c
.in +1c
.ti -1c
.RI "#define \fBYOVF\fP   (1 << 7)"
.br
.RI "\fIX overflow. \fP"
.ti -1c
.RI "#define \fBXOVF\fP   (1 << 6)"
.br
.RI "\fIY overflow. \fP"
.ti -1c
.RI "#define \fBYSGN\fP   (1 << 5)"
.br
.RI "\fISign of data packet byte 3 (y movement). \fP"
.ti -1c
.RI "#define \fBXSGN\fP   (1 << 4)"
.br
.RI "\fISign of data packet byte 2 (x movement). \fP"
.ti -1c
.RI "#define \fBMBT\fP   (1 << 2)"
.br
.RI "\fIMiddle button. \fP"
.ti -1c
.RI "#define \fBRBT\fP   (1 << 1)"
.br
.RI "\fIRight button. \fP"
.ti -1c
.RI "#define \fBLBT\fP   (1 << 0)"
.br
.RI "\fILeft button. \fP"
.in -1c
.in -1c
.PP
.RI "\fBUtility macros to inquiry first byte of mouse data packet\fP"
.br
 
.PP
.in +1c
.in +1c
.ti -1c
.RI "#define \fBLEFT_BUTTON\fP(dt)   (((dt) & LBT) == LBT)"
.br
.RI "\fI1 if left button pressed \fP"
.ti -1c
.RI "#define \fBRIGHT_BUTTON\fP(dt)   (((dt) & RBT) == RBT)"
.br
.RI "\fI1 if right button pressed \fP"
.ti -1c
.RI "#define \fBMIDDLE_BUTTON\fP(dt)   (((dt) & MBT) == MBT)"
.br
.RI "\fI1 if middle button pressed \fP"
.ti -1c
.RI "#define \fBY_OVERFLOW\fP(dt)   (((dt) & XOVF) == XOVF)"
.br
.RI "\fI1 if overflow in x movement \fP"
.ti -1c
.RI "#define \fBX_OVERFLOW\fP(dt)   (((dt) & YOVF) == YOVF)"
.br
.RI "\fI1 if overflow in y movement \fP"
.ti -1c
.RI "#define \fBX_SIGN\fP(dt)   (((dt) & XSGN) == XSGN ? -1 : 1)"
.br
.RI "\fI1 if positive x movement, -1 if negative \fP"
.ti -1c
.RI "#define \fBY_SIGN\fP(dt)   (((dt) & YSGN) == YSGN ? -1 : 1)"
.br
.RI "\fI1 if positive y movement, -1 if negative \fP"
.in -1c
.in -1c
.SS "Functions"

.in +1c
.ti -1c
.RI "int \fBkbc_init\fP (int debug)"
.br
.ti -1c
.RI "void \fBmouse_disable\fP (void)"
.br
.ti -1c
.RI "int \fBwrite_kbc_cmd\fP (unsigned data)"
.br
.ti -1c
.RI "int \fBhas_DOS_mouse_ISR\fP ()"
.br
.ti -1c
.RI "int \fBwrite_kbc_data\fP (unsigned data)"
.br
.ti -1c
.RI "int \fBwrite_aux\fP (unsigned cmd)"
.br
.ti -1c
.RI "int \fBread_kbc\fP (void)"
.br
.ti -1c
.RI "int \fBwrite_kbc\fP (unsigned adr, unsigned data)"
.br
.ti -1c
.RI "void \fBblink_leds\fP (void)"
.br
.ti -1c
.RI "void \fBblink_led\fP (\fBuchar\fP led)"
.br
.ti -1c
.RI "void \fBinitKeyBoard\fP (void(*t0_handler)(void))"
.br
.ti -1c
.RI "void \fBendKeyBoard\fP ()"
.br
.ti -1c
.RI "void \fBhandler_keyboard\fP ()"
.br
.ti -1c
.RI "void \fBinitMouse\fP (void(*mouse_handler)(void))"
.br
.ti -1c
.RI "void \fBendMouse\fP ()"
.br
.in -1c
.SS "Variables"

.in +1c
.ti -1c
.RI "_go32_dpmi_seginfo \fBkeyboard_new_irq\fP"
.br
.ti -1c
.RI "_go32_dpmi_seginfo \fBkeyboard_old_irq\fP"
.br
.ti -1c
.RI "_go32_dpmi_seginfo \fBmouse_old_irq\fP"
.br
.ti -1c
.RI "\fBQueue\fP \fBqueue_keyboard\fP"
.br
.ti -1c
.RI "volatile int \fBmouse_dx\fP"
.br
.ti -1c
.RI "volatile int \fBmouse_dy\fP"
.br
.in -1c
.SH "Variable Documentation"
.PP 
.SS "_go32_dpmi_seginfo \fBkeyboard_new_irq\fP"
.SS "_go32_dpmi_seginfo \fBkeyboard_old_irq\fP"
.SS "volatile int \fBmouse_dx\fP"
.SS "volatile int \fBmouse_dy\fP"
.SS "_go32_dpmi_seginfo \fBmouse_old_irq\fP"
.SH "Author"
.PP 
Generated automatically by Doxygen for Colision from the source code.
